<div class="content-table">
    <?php
        echo $this->partial('topo_list.phtml', array(
            'titulo' => $this->titulo,
            'controller' => $this->controller, 
            'action' => $this->action, 
            'search' => $this->search,
            'add'   =>  FALSE, 
            'form_search' => TRUE,
        ));
    ?>
    <table id="tlist" class="tb_content">
        <thead>
            <tr>
                <th style="width:20px;">Ordem</th>
                <th>Nome</th>
                <th>N&ring;/Qtd</th>
                <th>Tipo Material</th>
                <th>&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach($this->result as $row) { 
                $rep = $row->findDependentRowSet("Ead_Model_DbTable_Repositorio");  
                $obj = new Ead_Model_DbTable_Tipomaterial();
                $tip = $obj->fetchRow('TIP_ID = ' . $rep[0]['TIP_ID'])->toArray();
                
            ?>
                <tr>  
                    <td><?php echo $row->CON_ORD; ?></td>
                    <td align="left"><?php echo $row->CON_NOM; ?></td>
                    <td align="left"><?php echo $rep[0]['REP_PRTNUM'].'/'.$rep[0]['REP_PRTQTD']; ?></td>
                    <td align="left"><?php echo $tip['TIP_NOM']; ?></td>
                    <td>
                        <?php if($rep[0]['TIP_ID'] == 1){ ?>
                        <a class="btn-edt-list" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'material', 'id' => $row->CON_ID)); ?>">Acessar Vídeo</a>
                        <?php } else { 
                            $obj = new Ead_Model_DbTable_Conteudo();
                            $mat = $obj->fetchRow('CON_ID = ' . $row->CON_ID);
                            $rep = $mat->findDependentRowSet("Ead_Model_DbTable_Repositorio");
                            $aquivoNome = md5($rep[0]['REP_ID'].$rep[0]['REP_DATHOR']).'.*';
                            $arquivo = 'public/upload/repositorio/'.$aquivoNome;
                            foreach(glob($arquivo) as $src) {
                                $url = $src;
                            }
            
                        ?>
                        <a class="btn-edt-list" href="<?php echo $this->urlbase.'/'.$url; ?>" target="_blank">Baixar Material</a>
                        <?php } ?>
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
<?php echo $this->partial('rodape_btn.phtml', array('url_return'=>$this->url_return,'a_title'=>$this->a_title)); ?>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>